package com.teamc.team.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.teamc.team.entity.Class;
import com.teamc.team.mapper.ClassMapper;
import com.teamc.team.service.IClassService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ding
 * @since 2021-06-10
 */
@Service
public class ClassServiceImpl extends ServiceImpl<ClassMapper, Class> implements IClassService {

    @Autowired
    private ClassMapper mapper;

    @Override
    public void addClass(Class x) {
        mapper.insert(x);
    }

    @Override
    public void delClass(String x) {
        HashMap<String, Object> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("class_id",x);
        mapper.deleteByMap(stringStringHashMap);
    }

    @Override
    public void changeClassTEL(Integer classID, String classTEL) {
        UpdateWrapper<Class> classUpdateWrapper = new UpdateWrapper<>();
        classUpdateWrapper.eq("class_id",classID).set("class_tel",classTEL);
        mapper.update(null, classUpdateWrapper);
    }
}
